import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { NativeProvider } from '../../providers/native/native';

/**
 * Generated class for the SettingPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-setting',
  templateUrl: 'setting.html',
})
export class SettingPage {
  address: string;
  mettingaddress:any;
  constructor(public navCtrl: NavController, public navParams: NavParams, private native: NativeProvider) {
    this.address = localStorage.getItem("address");
    this.mettingaddress = localStorage.getItem("mettingaddress");
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad SettingPage');
  }
  savesetting() {
    if (this.address == null || this.address == '') {
      alert("服务地址为空!");
      return;
    }
    let indexM = this.address.lastIndexOf(":");
    this.mettingaddress = this.address.substr(0,indexM)+":9001";
    localStorage.setItem("address", this.address);
    localStorage.setItem("mettingaddress",this.mettingaddress);
    this.native.showToast("保存成功！");
    this.navCtrl.pop();
  }
}
